package com.winchain.chainbill.risk.biz.access.cmd;

import com.shell.bee.acct.transaction.po.AcctTxRec;
import com.shell.framework.command.CallbackContext;
import com.shell.framework.command.CommandContext;
import com.shell.framework.command.ICallback;
import com.winchain.chainbill.risk.base.po.RmAccessQuota;
import org.springframework.stereotype.Component;

@Component
public class AccessQuotaRollbackCmd extends AccessQuotaCmd implements ICallback<RmAccessQuota, AcctTxRec> {
	public boolean callback(CallbackContext<RmAccessQuota, AcctTxRec> context) throws Exception {
		rollback(context);
		return false;
	}

	private boolean rollback(CommandContext<RmAccessQuota> context) throws Exception {
		AcctTxRec tx = getTxRec(context);
		String optType = tx.getOptType();
		if ("qt_inc".equals(optType)) {
			optType = "qt_red";
		} else if ("qt_red".equals(optType)) {
			optType = "qt_inc";
		}
		return false;
	}
}
